package Servlet;

import Damain.emp;
import Service.EmpUpdateUiService;
import Service.EmpUpdateUiServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 跳转到修改界面
 *
 */
@WebServlet(name = "EmpUpdateUiServlet", urlPatterns = "/empUpdateuiServlet")
public class EmpUpdateUiServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //获取到id
        String Sid = request.getParameter("id");
        //转换
        int id = Integer.parseInt(Sid);
        //调用持久层业务
        EmpUpdateUiService empUpdateUiService = new EmpUpdateUiServiceImpl();
        //调用方法通过id查询
        emp emp = empUpdateUiService.SelEmpById(id);

        request.setAttribute("emp", emp);
//跳转修改页面
        request.getRequestDispatcher("/pages/empupdate.jsp").forward(request, response);

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
